
/**		
 * 
 *	uk.co.lmfm.guppy.application.ApplicationFacade
 *	
 *	@version 1.00 | Jan 7, 2010
 *	@author Justin Windle
 *  
 **/
 
package uk.co.lmfm.guppy.application
{
	import uk.co.lmfm.guppy.controller.ForceRepositoryCheckoutCommand;
	import uk.co.lmfm.guppy.controller.AutoSetupCommand;
	import uk.co.lmfm.guppy.application.enum.ApplicationConstants;
	import uk.co.lmfm.guppy.controller.CheckoutCompleteCommand;
	import uk.co.lmfm.guppy.controller.CloneWorkspaceCommand;
	import uk.co.lmfm.guppy.controller.CompareRepositoriesCommand;
	import uk.co.lmfm.guppy.controller.ConfigureWorkspaceCommand;
	import uk.co.lmfm.guppy.controller.CreateProjectCommand;
	import uk.co.lmfm.guppy.controller.CreateWorkspaceCommand;
	import uk.co.lmfm.guppy.controller.GetConfigCommand;
	import uk.co.lmfm.guppy.controller.GetUserSettingsCommand;
	import uk.co.lmfm.guppy.controller.GetWorkspacesCommand;
	import uk.co.lmfm.guppy.controller.InitialiseCommand;
	import uk.co.lmfm.guppy.controller.SDKDownloadCompleteCommand;
	import uk.co.lmfm.guppy.controller.SVNLogReportCommand;
	import uk.co.lmfm.guppy.controller.SetLibraryPathCommand;
	import uk.co.lmfm.guppy.controller.SetUserSettingsCommand;
	import uk.co.lmfm.guppy.controller.StartupCommand;
	import uk.co.lmfm.guppy.controller.UpdateFlexSDKCommand;
	import uk.co.lmfm.guppy.model.vo.StartupVO;

	import org.puremvc.as3.multicore.interfaces.IFacade;
	import org.puremvc.as3.multicore.patterns.facade.Facade;
	import org.puremvc.as3.multicore.patterns.observer.Notification;

	/**
	 * ApplicationFacade
	 */
	public class ApplicationFacade extends Facade implements IFacade 
	{
		public function ApplicationFacade(key : String)
		{
			super(key);
		}

		//	----------------------------------------------------------------
		//	PUBLIC METHODS
		//	----------------------------------------------------------------

		public static function getInstance( key : String ) : ApplicationFacade
		{
			if ( instanceMap[ key ] == null ) instanceMap[ key ] = new ApplicationFacade(key);
			return instanceMap[ key ] as ApplicationFacade;
		}

		public function startup(vo : StartupVO) : void
		{
			notifyObservers(new Notification(ApplicationConstants.STARTUP, vo));
		}

		//	----------------------------------------------------------------
		//	PROTECTED METHODS
		//	----------------------------------------------------------------

		override protected function initializeController() : void
		{
			super.initializeController();
			
			// General

			registerCommand(ApplicationConstants.STARTUP, StartupCommand);			registerCommand(ApplicationConstants.INITIALISE, InitialiseCommand);
			
			// Settings

			registerCommand(ApplicationConstants.GET_USER_SETTINGS, GetUserSettingsCommand);			registerCommand(ApplicationConstants.SET_USER_SETTINGS, SetUserSettingsCommand);
			
			// Config

			registerCommand(ApplicationConstants.AUTO_SETUP_REQUEST, AutoSetupCommand);			registerCommand(ApplicationConstants.SET_LIBRARY_PATH, SetLibraryPathCommand);			registerCommand(ApplicationConstants.GET_CONFIG, GetConfigCommand);
			
			// SVN

			registerCommand(ApplicationConstants.GOT_REPOSITORY_LATEST_REVISION_NUMBER, CompareRepositoriesCommand);
			registerCommand(ApplicationConstants.FORCE_REPOSITORY_CHECKOUT, ForceRepositoryCheckoutCommand);			registerCommand(ApplicationConstants.SVN_LOG_REPORT_RECIEVED, SVNLogReportCommand);
			registerCommand(ApplicationConstants.CHECKOUT_COMPLETE, CheckoutCompleteCommand);
			
			// SDK

			registerCommand(ApplicationConstants.UPDATE_FLEX_SDKS, UpdateFlexSDKCommand);			registerCommand(ApplicationConstants.SDK_DOWNLOAD_COMPLETE, SDKDownloadCompleteCommand);
			
			// Workspace

			registerCommand(ApplicationConstants.GET_WORKSPACES, GetWorkspacesCommand);			registerCommand(ApplicationConstants.CLONE_WORKSPACE, CloneWorkspaceCommand);			registerCommand(ApplicationConstants.CREATE_WORKSPACE, CreateWorkspaceCommand);
			registerCommand(ApplicationConstants.CONFIGURE_WORKSPACE, ConfigureWorkspaceCommand);
			
			// Project

			registerCommand(ApplicationConstants.CREATE_PROJECT, CreateProjectCommand);
		}
	}
}
